<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑个人信息 - 智淘GO</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background: url('https://pic2.zhimg.com/v2-86ffa1ad12c00587d5cb6f9bd362578a_r.jpg?source=1940ef5c') no-repeat center center fixed;
            background-size: cover;
            font-family: 'Arial', sans-serif;
        }
        .edit-form-container {
            background: rgba(255, 255, 255, 0.9);
            border-radius: 15px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
            padding: 2rem;
            margin: 2rem auto;
            max-width: 800px;
        }
        .form-title {
            color: #e67e22;
            border-bottom: 2px solid #e67e22;
            padding-bottom: 0.5rem;
            margin-bottom: 1.5rem;
            font-weight: bold;
        }
        .form-group {
            margin-bottom: 1.5rem;
        }
        .form-group label {
            font-weight: 500;
            color: #34495e;
        }
        .form-control {
            border-radius: 8px;
            padding: 0.75rem 1rem;
            border: 1px solid #ddd;
            transition: all 0.3s ease;
        }
        .form-control:focus {
            border-color: #e67e22;
            box-shadow: 0 0 5px rgba(230, 126, 34, 0.3);
        }
        .btn-submit {
            background: linear-gradient(135deg, #e67e22, #d35400);
            color: white;
            padding: 10px 30px;
            border-radius: 25px;
            border: none;
            transition: all 0.3s ease;
            font-weight: bold;
        }
        .btn-submit:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(230, 126, 34, 0.4);
        }
        .btn-cancel {
            background: #e74c3c;
            color: white;
            padding: 10px 30px;
            border-radius: 25px;
            border: none;
            transition: all 0.3s ease;
        }
        .btn-cancel:hover {
            background: #c0392b;
            transform: translateY(-2px);
        }
        .navbar {
            background: rgba(230, 126, 34, 0.9) !important;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        .navbar-brand, .nav-link {
            color: white !important;
        }
        .nav-link:hover {
            color: #f8c291 !important;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark mb-4">
        <div class="container">
            <a class="navbar-brand" href="#">智淘GO</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'center' %}">返回个人中心</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 编辑表单 -->
    <div class="container">
        <div class="edit-form-container">
            <h2 class="form-title">编辑个人信息</h2>
            <form method="post" enctype="multipart/form-data">
                {% csrf_token %}

                <!-- 学号 -->
                <div class="form-group">
                    <label for="id_student_id">学号</label>
                    {{ form.student_id }}
                    <small class="form-text text-muted">请输入您的学号</small>
                </div>

                <!-- 手机号码 -->
                <div class="form-group">
                    <label for="id_mobile">手机号码</label>
                    {{ form.mobile }}
                    <small class="form-text text-muted">请输入有效的手机号码</small>
                </div>

                <!-- 性别 -->
                <div class="form-group">
                    <label for="id_gender">性别</label>
                    {{ form.gender }}
                </div>

                <!-- 身份证号 -->
                <div class="form-group">
                    <label for="id_id_card">身份证号</label>
                    {{ form.id_card }}
                    <small class="form-text text-muted">请输入18位身份证号码</small>
                </div>

                <!-- 出生日期 -->
                <div class="form-group">
                    <label for="age">年龄</label>
                    {{ form.age }}
                </div>

                <!-- 按钮组 -->
                <div class="d-flex justify-content-between mt-4">
                    <button type="submit" class="btn btn-submit">保存修改</button>
                    <a href="{% url 'center' %}" class="btn btn-cancel">取消</a>
                </div>
            </form>
        </div>
    </div>

    <!-- Bootstrap 5 JS -->
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
    <!-- 表单验证脚本 -->
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const mobileInput = document.getElementById('id_mobile');
            const idCardInput = document.getElementById('id_id_card');

            mobileInput.addEventListener('input', function() {
                this.value = this.value.replace(/\D/g, '').slice(0, 11);
            });

            idCardInput.addEventListener('input', function() {
                this.value = this.value.replace(/\D/g, '').slice(0, 18);
            });
        });
    </script>
</body>
</html>